import javax.swing.JDialog;
import javax.swing.JComboBox;

import javax.swing.JButton;
import javax.swing.JLabel;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;



/**
 * Creates the dialog for adding a Nurse.
 * 
 * @author Lsun
 */
@SuppressWarnings("serial")
public class AddUserDialog extends JDialog {
	private JComboBox comboBox;
	private JDialog adp;

	/**
	 * Creates the dialog.
	 *
	 * @param mac The MedAppController that drives this dialog.
	 */ 
	public AddUserDialog(final MedAppController mac) {
		setTitle("Select User Type");
		setBounds(100, 100, 318, 191);
		
		comboBox = new JComboBox();
		comboBox.setBounds(48, 52, 202, 36);
		comboBox.addActionListener(new ActionListener() {
			/**
			 * Designed to perform the action specified upon triggering.
			 * 
			 * @param arg0 The ActionEvent that triggers the method call.
			 */ 
			public void actionPerformed(ActionEvent arg0) {
				if (comboBox.getSelectedItem() == "Patient") {
					 adp = new AddPatientDialog(mac);
				} else if (comboBox.getSelectedItem() == "Doctor") {
					 adp = new AddDoctorDialog(mac);
				} else if (comboBox.getSelectedItem() == "Nurse") {
					 adp = new AddNurseDialog(mac);
				}
			}
		});
		getContentPane().setLayout(null);
		comboBox.addItem("Patient");
		comboBox.addItem("Doctor");
		comboBox.addItem("Nurse");
		getContentPane().add(comboBox);
		
		JButton btnSelect = new JButton("Select");
		btnSelect.setBounds(77, 100, 148, 36);
		btnSelect.addActionListener(new ActionListener() {
			/**
			 * Designed to perform the action specified upon triggering.
			 * 
			 * @param arg0 The ActionEvent that triggers the method call.
			 */ 
			public void actionPerformed(ActionEvent arg0) {
					adp.setVisible(true);
					dispose();
			}
		});
		getContentPane().add(btnSelect);
		
		JLabel lblPleaseSelectUser = new JLabel("Please select user type:");
		lblPleaseSelectUser.setBounds(48, 22, 214, 19);
		getContentPane().add(lblPleaseSelectUser);
	}
}
